home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: argc/argv & switches
- Date: Thu, 07 Mar 96 17:36:39 GMT
- Organization: none
- Message-ID: <826220199snz@genesis.demon.co.uk>
- References: <4h2j8j$9gn@milo.freenet.vancouver.bc.ca> <danpop.825593142@rscernix> <313E0094.167EB0E7@fore.com> <4hl52oINNa4l@anvil.ugrad.cs.ubc.ca>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <4hl52oINNa4l@anvil.ugrad.cs.ubc.ca>
- c2a192@ugrad.cs.ubc.ca "Kazimir Kylheku" writes:
-
- >However, if it were the case that these pointers are not modifiable, would not
- >the declaration of main() be required to be written as:
- >
- >int main(int argc, char * const *argv)
- >
- > or
- >
- >int main(int argc, char * const argv[])
- >
- >That is, ``argv is a pointer to a vector of constant pointers to modifiable
- >chars''.
-
- This is not required any more than the type of a string literal is required
- to be const char [x]. You can refer to a const object through a non-const
- lvalue however if you try to modify the object you get undefined
- behaviour. The const was probably left out to maintain backwards compatibilty
- with existing code. Such code could easily contain lines such as:
-
- char **ptr = argv;
-
- which would break with a const declaration of argv. Of course the standard
- declaration breaks if I try to use:
-
- char *const *ptr = argv;
-
- which is a pity but not disasterous!
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-